package com.sjb.singleSingleton;

import java.util.concurrent.atomic.AtomicLong;

/**
 * Created with IntelliJ IDEA.
 * 饿汉式 单例模式 以生成全局唯一id为例
 * @Author: 有点儿意思
 * @Description:
 */
public class HungrySingleton {

    private static final HungrySingleton intStance = new HungrySingleton();
    private AtomicLong id = new AtomicLong(0);
    private HungrySingleton(){}

    public HungrySingleton getInstance(){
        return intStance;
    }

    public long getId(){
        return id.incrementAndGet();
    }
}
